<template>
  <el-form  :model="formData" label-width="120px" ref="form" v-loading="loading" class="pr-4 create-theweek">
    <el-form-item label="生产用料清单 :" prop="fbillno">
      {{ formData.fbillno }}
    </el-form-item>
    <el-form-item label="产品SKU :" prop="fmaterialid">
      {{ formData.fmaterialid }}
    </el-form-item>
    <el-form-item label="产品名称 :" prop="fmaterialname">
      {{ formData.fmaterialname }}
    </el-form-item>
    <el-form-item label="生产车间 :" prop="fworkshopid_name">
      {{ formData.fworkshopid_name }}
    </el-form-item>
    <el-form-item label="生产线 :" prop="fline">
      {{ formData.fline }}
    </el-form-item>

    <el-form-item label="计划配置类型 :" prop="plantype">
      <el-select v-model="formData.plantype" placeholder="选择计划配置类型">
        <el-option v-for="item in props.plantypeArr" :key="item.value" :label="item.label" :value="item.value" />
      </el-select>
    </el-form-item>
    <el-form-item
      label="计划生产日期 :"
      prop="fplannedstarttime"
      placeholder="请输入计划生产日期"
      :rules="[
        {
          required: true,
          message: '计划生产日期不能为空',
        },
      ]"
    >
    <el-date-picker v-model="formData.fplannedstarttime" value-format="YYYY-MM-DD"  type="date"  />
    </el-form-item>
    <el-form-item
      label="计划生产数量 :"
      prop="planqty"
      placeholder="请输入计划生产数量"
      :rules="[
        {
          required: true,
          message: '计划生产数量不能为空',
        },
      ]"
    >
      <el-input v-model="formData.planqty" clearable width="150" />
    </el-form-item>
    <el-form-item
      label="计划人工 :"
      prop="plan_labor"
      placeholder="请输入计划人工"
      :rules="[
        {
          required: true,
          message: '计划人工不能为空',
        },
      ]"
    >
      <el-input v-model="formData.plan_labor" clearable width="150" />
    </el-form-item>
    <el-form-item
      label="计划生产时长 :"
      prop="production_time"
      placeholder="请输入计划生产时长"
      :rules="[
        {
          required: true,
          message: '计划生产时长不能为空',
        },
      ]"
    >
      <el-input v-model="formData.production_time" clearable width="150" />
    </el-form-item>
    <el-form-item
      label="计划总工时 :"
      prop="plan_total"
      placeholder="请输入计划总工时"
      :rules="[
        {
          required: true,
          message: '计划总工时不能为空',
        },
      ]"
    >
      <el-input v-model="formData.plan_total" clearable width="150" />
    </el-form-item>
    <el-form-item
      label="备注 :"
      prop="remark"
      placeholder="请输入备注"
    >
      <el-input v-model="formData.remark" clearable width="150" />
    </el-form-item>
    <div class="flex justify-end">
      <el-button type="primary" @click="submitForm(form)">{{ $t('system.confirm') }}</el-button>
    </div>
  </el-form>
</template>

<script lang="ts" setup>
import { useCreate } from '/admin/composables/curd/useCreate'
import { useShow } from '/admin/composables/curd/useShow'
import { onMounted } from 'vue'

const props = defineProps({
  primary: String | Number,
  api: String,
  plantypeArr: Array,
})

const { formData, form, loading, submitForm, close } = useCreate(props.api, props.primary)

if (props.primary) {
  useShow(props.api, props.primary, formData)
  console.log(formData.value);


}

const emit = defineEmits(['close'])
onMounted(() => {
  close(() => emit('close'))
})
</script>

<style>
.create-theweek .el-form-item{
  margin-bottom: 5px;
}
</style>
